home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 25
/
Cream of the Crop 25.iso
/
os2
/
srefv12i.zip
/
acceschk.rxx
< prev
next >
Wrap
Text File
|
1996-11-05
|
6KB
|
244 lines
/* Check acesss privs module for SRE-FILTER. Uses contents of accessfile
Standard arguments on initialization: access_file, queue, semaphore
Caller places on queue: newq,newsem,AURL
This put on newq: amatch,privs,options,realm
amatch= entry number of match (0 if NOt match)
privs = entry privileges
options = CACHE NOSSI NOSSP
realm = realm to use for "ask client for id stuff"
Options and realm are often not available.
*/
parse upper arg accessfile, usequeue , USESEM, max_semwait
call pmprintf(' SRE-FILTER Access Thread: accessfile='||accessfile)
call pmprintf(' SRE-FILTER Access Thread: queue='||usequeue)
call pmprintf(' SRE-FILTER Access Thread: semaphore='||usesem)
mytid=dostid()
call pmprintf(' SRE-FILTER Access Thread: thread id='||mytid)
resetit:
if usequeue="" | USESEM="" then do
call pmprintf('SRE-FILTER Access thread: initialization ERROR: '||usequeue)
exit
end
call set_access(accessfile)
if naccess=0 then do
call pmprintf(' SRE-FILTER access thread: Warning: No valid entries in access file:'||accessfile)
end
else do
call pmprintf(' SRE-FILTER access thread: #acesss entries='||naccess)
end
/* Initialization now done == start waiting for requests for access info */
signal on error name iserror
signal on syntax name iserror
bakme:
a=rxqueue('s',usequeue)
aq=queued()
if aq=0 then do
WOW=EVENTSEM_WAIT(USESEM,max_semwait)
aq=-1
if wow=640 then do
signal bakme
end
IF WOW<>0 THEN do /* FATAL ERROR */
call pmprintf(' Fatal error in access thread 'wow)
EXIT
end
end
wow=EVENTSEM_RESET(usesem)
if aq=-1 then
if queued()=0 then signal bakme
pull isit0
isit0=upper(translate(isit0,' ','000d0a09'x))
if isit0=" " then signal bakme
parse var isit0 idnum ',' newq ',' newsem ',' ISIT
parse var idnum idnum host_nickname
if newq="" | newsem="" then do
call pmprintf(' SRE-FILTER access Thread: missing queue or semaphore ')
signal bakme
end
newq=strip(newq); newsem=strip(newsem) ; ISIT=STRIP(ISIT)
if abbrev(strip(translate(isit)),'*DIE*') then
exit
if abbrev(strip(translate(isit)),'*RESET*') then do
parse var isit foo newfile .
if newfile<>' ' then accessfile=newfile
call set_access(accessfile)
call pmprintf(' SRE-Filter access: Reread access file:'accessfile)
end
else do
if naccess=0 then
dog1=' 0 '
else do
dog1=fig_access(isit,host_nickname)
end
a=rxqueue('s',newq)
push idnum ',' dog1
wow=eventsem_post(newsem)
end
signal bakme
iserror:
signal off error ; signal off syntax
call pmprintf(' error in access : resetting ')
a=rxqueue('d',usequeue)
a=rxqueue('c',usequeue)
a=eventsem_close(usesem)
a=eventsem_create(usesem)
a=rxqueue('s',newq)
push idnum ', 0 '
wow=eventsem_post(newsem)
call pmprintf(' done resetting access ')
signal on error name iserror
signal on syntax name iserror
signal bakme
exit
/* ---------- */
fig_access:procedure expose urls. privs. opts. realms. nrealms realm_names. realm_privs. hosturls.
parse arg inline,host_nickname
inline=strip(translate(inline,' ','000d0a09'x))
inline=translate(inline,'/','\')
inline=strip(inline,'l','/')
host_nickname=strip(upper(host_nickname))
/* got a request -- look for a match */
doexact=0
gotit=0
starat=0 ; afterstar=0
do mm=1 to urls.0
if hosturls.mm<>host_nickname & hosturls.mm<>' ' then iterate
ma1=urls.mm
ares=sref_wildcard(inline,ma1,doexact)
parse var ares astat "," aurl ; astat=strip(astat)
if astat=0 then iterate /* no match */
if astat=1 then do
gotit=mm
leave /*first exact match rules */
end
else do
parse var ma1 ma1a ma1b
t1=pos('*',ma1a)
t33=length(ma1a)-t1
if t1 >= starat then do
if t1 > starat | t33>afterstar then do
starat=t1 ; afterstar=t33
gotit=mm
end
end
end
end
if gotit=0 then
return gotit
pgot=privs.gotit
if realms.gotit<>"" then do /* find realm privs? */
do nn1=1 to nrealms
if realms.gotit=realm_names.nn1 then do
pgot=pgot||' '||realm_privs.nn1
leave
end
end
end
return gotit ' , ' pgot ',' opts.gotit ', ' realms.gotit
/* ---------------- */
/* read and set up access privs */
set_access:
parse arg afile
naccess=0
nrealms=0
urls.0=0
a=fileread(afile,'ulist',,'E') /* read it to a stem variable */
foo=do_extends(0)
if a=0 then do
call pmprintf(' SRE-FILTER access thread: ERROR reading access-file: '||afile)
return 0
end
do mm=1 to ulist.0
t1=translate(strip(ulist.mm))
if abbrev(t1,';')=1 | t1=' 'then
iterate
ahost=' '
t1w=strip(upper(word(t1,1)))
if right(t1w,2)='//' then do
ahost=left(t1w,length(t1w)-2)
t1=strip(delword(t1,1,1))
end
if upper(word(t1,1))='!REALM' then do
nrealms=nrealms+1
parse upper var t1 foo1 realm_names.nrealms realm_privs.nrealms
iterate
end
parse upper var t1 aurl privs ',' options ',' realm
naccess=naccess+1
aurl=strip(aurl)
aurl=translate(aurl,'/','\')
aurl=strip(aurl,'l','/')
urls.naccess=aurl
privs.naccess=strip(privs)
opts.naccess=strip(options)
realms.naccess=strip(realm)
hosturls.naccess=ahost
end
urls.0=naccess
return 0
/************/
/* Redo ulist, by treating lines starting with , as continuation lines */
do_extends:procedure expose ulist.
if ulist.0=0 then return 0
isnew=1
tmps.1=ulist.1
do mm=2 to ulist.0
ali=strip(ulist.mm)
if abbrev(ali,',')=0 then do
isnew=isnew+1
tmps.isnew=ulist.mm
end
else do
tmps.isnew=tmps.isnew||substr(ali,2)
end
end
do mm=1 to isnew
ulist.mm=tmps.mm
end
ulist.0=isnew
return 0